import React, { FC } from "react";
import classNames from "classnames";
import { FontAwesomeIcon, FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
import { library } from "@fortawesome/fontawesome-svg-core";
import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";

library.add(
	faSpinner,
);

export type ThemeProps =
	| "primary"
	| "secondary"
	| "success"
	| "info"
	| "warning"
	| "danger"
	| "light"
	| "dark"
	| "default";

export interface IconProps extends FontAwesomeIconProps {
	theme?: ThemeProps;
}

export const Icon: FC<IconProps> = (props) => {
	const { className, theme, ...restProps } = props;
	const classes = classNames("bigbear-icon", className, {
		[`icon-${theme}`]: theme
	});
	return <FontAwesomeIcon className={classes} {...restProps} />;
};

export default Icon;
